<template>
  <BasicDrawer v-bind="$attrs" @register="registerDrawer" title="用户详情" width="700px">
    <Description @register="registerDescription" :data="detailData" />
  </BasicDrawer>
</template>
<script lang="ts" setup>
  import { ref } from "vue"
  import { BasicDrawer, useDrawerInner } from "/@/components/Drawer"
  import { detailSchema } from "./user.data"
  import { getUserDetails } from "./user.api"
  import { Description, useDescription } from "/@/components/Description/index"
  const detailData = ref({})

  const tenantId = ref()
  const emit = defineEmits(["success", "register"])
  const [registerDescription] = useDescription({
    column: 2,
    bordered: false,
    // data: mockData,
    schema: detailSchema,
    labelStyle: {
      marginLeft: "10px",
    },
  })

  const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
    setDrawerProps({ confirmLoading: false })
    console.log("record: ", data.record)
    try {
      setDrawerProps({ loading: true })
      detailData.value = await getUserDetails({ userId: data.record.id })
    } finally {
      setDrawerProps({ loading: false })
    }
  })
</script>
